# coding:utf-8
"""
description:SETTINGS页面
"""
import os
import random
import time

from appium.webdriver.common import mobileby
from pages.Public_elements import public_elements
from common.Gesture_Mainpulation import gesture_mainpulation
from common.Get_Yaml import get_yaml
from common.Log import LOG
from config.GlobalParameter import TEST_Element_YAML

Scenes_Data = get_yaml(os.path.join(TEST_Element_YAML, 'Setting.yaml'))


class Setting_page(public_elements):
    by = mobileby.MobileBy()

    """点击Language一行，不测试"""
    LanguageLine_loc = (by.ID, Scenes_Data.get_elementInfo(0))
    """点击Notifications一行，开启关闭，无法判断，弹框element见Public.yaml（1、2）"""
    NotificationsLine_loc = (by.ID, Scenes_Data.get_elementInfo(1))
    """点击Vibrate on Touch一行，无法判断"""
    VibrateLine_loc = (by.ID, Scenes_Data.get_elementInfo(2))

    """点击Alexa一行"""
    AmazonAlexaLine_loc = (by.ID, Scenes_Data.get_elementInfo(3))
    """点击Google一行"""
    GoogleLine_loc = (by.ID, Scenes_Data.get_elementInfo(4))

    def click_LanguageLine(self):
        """点击Language一行，不测试"""
        self.find_element(*self.LanguageLine_loc).click()

    def get_NotificationSwitch(self):
        """点击Notifications一行，开启关闭，无法判断，弹框element见Public.yaml（1、2）"""
        return self.find_element(*self.NotificationsLine_loc)

    def func_NotificationSwitch(self):
        """点击Alexa一行,跳转页面，断言页标题"""
        if self.get_NotificationSwitch().get_attribute("checked") == 'false':
            self.get_NotificationSwitch().click()  # 如果单选为‘false’，点击后为选中
        self.get_NotificationSwitch().click()  # 如果switch是打开状态，点击后弹框是否取消选中
        super().click_cancel()
        self.get_NotificationSwitch().click()
        super().click_confirm()

    def click_VibrateLine(self):
        """点击Vibrate on Touch一行，点击后切换开关，无法判断"""
        self.find_element(*self.VibrateLine_loc).click()

    def click_AmazonAlexaLine(self):
        """点击Alexa一行"""
        self.find_element(*self.AmazonAlexaLine_loc).click()

    def func_AmazonAlexa(self, CheckT):
        """点击Alexa一行,跳转页面，断言页标题"""
        self.click_AmazonAlexaLine()
        return super().find_toast(CheckT)

    def click_GoogleLine(self):
        """点击Google一行"""
        self.find_element(*self.GoogleLine_loc).click()

    def func_Google(self, CheckT):
        """点击Alexa一行,跳转页面，断言页标题"""
        self.click_GoogleLine()
        return super().find_toast(CheckT)
